pragma solidity 0.8.14; import "@openzeppelin/contracts@4.6.0/token/ERC20/ERC20.sol"; contract Crowdfund is ERC20 { event LogReceive(address _from, uint256 amount); event LogWithdraw(address _to, uint256 amount); address public founder; uint256 public constant rate = 100; constructor() ERC20("DeFi For Dummies", "DEFIFD"){ founder = msg.sender; _mint(founder, 1000*1000000000000000000); } receive() external payable { emit LogReceive(msg.sender, msg.value); _mint(msg.sender, msg.value * rate); } function withdraw(address payable _to, uint256 amount) public { require(msg.sender == founder, "not the founder"); require(address(this).balance >= amount, "insufficient funds"); _to.transfer(amount); emit LogWithdraw(_to, amount); } }